<?php
require_once("conf/db_connection.php");
$trip_id = $_GET['v0'];
$date = $_GET['v1'];
$time = $_GET['v2'];
$caller = $_GET['v3'];
$mobile = $_GET['v4'];
$type = $_GET['v5'];
$loc = $_GET['v6'];
$remarks = $_GET['v7'];

$query_insert = "INSERT INTO incident (trip_detail_id,incident_date,incident_time,caller,caller_mobile,incident_type,location,remarks,created_by) VALUES
('".$trip_id."',
'".$date."',
'".$time."',
'".$caller."',
'".$mobile."',
'".$type."',
'".$loc."',
'".$remarks."',
'".$_SESSION['username_nn']."')";
mysql_query($query_insert) or die("INSERT INCIDENT ".mysql_error());


$query_incident = "SELECT * FROM incident WHERE trip_detail_id='".$trip_id ."'";
$result_incident = mysql_query($query_incident) or die("SELECT INCIDENT ".mysql_error());
$num_rows_inc = mysql_num_rows($result_incident);
if($num_rows_inc>0)
{
	while($row_incident = mysql_fetch_array($result_incident))
	{
		$incident_table_list .= "<tr class='h25'>
		<td class='incl label'>".$row_incident['incident_date']." ".$row_incident['incident_time']."</td>
		<td class='incl label'>".$row_incident['incident_type']."</td>
		<td class='incl label'>".$row_incident['caller']."</td>
		<td class='incl label'>".$row_incident['caller_mobile']."</td>
		</tr>";
	}
}
else
{
	$incident_table_list = "<td class='incl label' colspan='4' style='padding-top:30px;'>No Incident Record</td>";
}


echo "<table id='pop_table' border='0' style='width:500px;'>
<thead style='height:15%;'>
<tr id='hor-minimalist-b'>
	<th>Date/Time</th>
	<th>Type</th>
	<th>Caller</th>
	<th>Mobile</th>
</tr>
</thead>
<tbody>
".$incident_table_list."
</tbody>
</table>";
?>